/**
 * 
 */
package kr.co.insoft.framework.resolver;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;

/**
 * @author IN-SOFT Inc. GoodwillDD(sylee@in-soft.co.kr)
 *
 */
@Component
public class MessageResolver {

	@Autowired
	MessageSource messageSource;
	
	public String message(final String code) {
		try {
			return messageSource.getMessage(code, null, LocaleContextHolder.getLocale());
		} catch (Exception e) {
			return code;
		}
	}
	
	public String message(final String code, final Object[] params) {
		try {
			return messageSource.getMessage(code, params, LocaleContextHolder.getLocale());
		} catch (Exception e) {
			return code;
		}
	}
}
